x11: make the tool lookup dependent on the hw id as well
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 14 Dec 2018 05:28:29 +0000 (15:28 +1000)
committerCarlos Garnacho <carlosg@gnome.org>
Tue, 18 Dec 2018 20:41:49 +0000 (21:41 +0100)
Tools on the same physical item have the same serial number, so the eraser
and the pen part of a single pen share that serial number. With the current
lookup code, we'll always return whichever tool comes first into proximity.

Change the code to use the hw id in addition to the serial number, this way we
can differ between two tools.

gdk/gdkseat.c
gdk/gdkseatdefault.c
gdk/gdkseatprivate.h
gdk/x11/gdkdevicemanager-xi2.c

index aa120f298b3ea40aae5af2b5ee19c042a70dff36..6edd3832063692bec7dcc567ff57484c1d35b7c6 100644 (file)
@@ -434,14 +434,15 @@ gdk_seat_tool_removed (GdkSeat       *seat,
 
 GdkDeviceTool *
 gdk_seat_get_tool (GdkSeat *seat,
-                   guint64  serial)
+                   guint64  serial,
+                   guint64  hw_id)
 {
   GdkSeatClass *seat_class;
 
   g_return_val_if_fail (GDK_IS_SEAT (seat), NULL);
 
   seat_class = GDK_SEAT_GET_CLASS (seat);
-  return seat_class->get_tool (seat, serial);
+  return seat_class->get_tool (seat, serial, hw_id);
 }
 
 /**
index 2de1c36c5fd639fd560d0cf6294065d948f76dc4..14dbb75f9799a27c2d092f9443a679e39707d6a9 100644 (file)
@@ -282,7 +282,8 @@ gdk_seat_default_get_slaves (GdkSeat             *seat,
 
 static GdkDeviceTool *
 gdk_seat_default_get_tool (GdkSeat *seat,
-                           guint64  serial)
+                           guint64  serial,
+                           guint64  hw_id)
 {
   GdkSeatDefaultPrivate *priv;
   GdkDeviceTool *tool;
@@ -297,7 +298,7 @@ gdk_seat_default_get_tool (GdkSeat *seat,
     {
       tool = g_ptr_array_index (priv->tools, i);
 
-      if (tool->serial == serial)
+      if (tool->serial == serial && tool->hw_id == hw_id)
         return tool;
     }
 
@@ -457,8 +458,7 @@ gdk_seat_default_remove_tool (GdkSeatDefault *seat,
 
   priv = gdk_seat_default_get_instance_private (seat);
 
-  if (tool != gdk_seat_get_tool (GDK_SEAT (seat),
-                                 gdk_device_tool_get_serial (tool)))
+  if (tool != gdk_seat_get_tool (GDK_SEAT (seat), tool->serial, tool->hw_id))
     return;
 
   g_signal_emit_by_name (seat, "tool-removed", tool);
index 97127dbfae197bd7e61e862918ade5fb35a5ca97..eaeecec8ff1980098f32b2d0971d40a87c891219 100644 (file)
@@ -57,7 +57,8 @@ struct _GdkSeatClass
                               GdkSeatCapabilities  capabilities);
 
   GdkDeviceTool * (* get_tool) (GdkSeat *seat,
-                                guint64  serial);
+                                guint64  serial,
+                                guint64  tool_id);
   GList *     (* get_master_pointers) (GdkSeat             *seat,
                                        GdkSeatCapabilities  capabilities);
 };
@@ -74,6 +75,7 @@ void gdk_seat_tool_removed   (GdkSeat       *seat,
 
 GdkDeviceTool *
      gdk_seat_get_tool       (GdkSeat   *seat,
-                              guint64    serial);
+                              guint64    serial,
+                              guint64    hw_id);
 
 #endif /* __GDK_SEAT_PRIVATE_H__ */
index 8c1cc41a709650ab2e9cbedde0b3c1c75b180571..01d51d3d3a7de113478289492d75ec46373ee955 100644 (file)
@@ -1096,7 +1096,7 @@ handle_property_change (GdkX11DeviceManagerXI2 *device_manager,
           device_get_tool_serial_and_id (device, &serial_id, &tool_id))
         {
           seat = gdk_device_get_seat (device);
-          tool = gdk_seat_get_tool (seat, serial_id);
+          tool = gdk_seat_get_tool (seat, serial_id, tool_id);
 
           if (!tool && serial_id > 0)
             {